package com.travel.server.manager.impl.sal;

import com.travel.server.manager.impl.enums.OrderStateEnum;
import com.travel.server.manager.impl.enums.OrderStepEnum;

import java.util.Arrays;
import java.util.List;

/**
 * @Author: LiZhenhui
 * @Date: 2018/11/8 18:26
 * @Desc:
 */
public class OrderStateSal {

    public final static List<String> WAIT_PAY = Arrays.asList(OrderStepEnum.APPLY_WAIT.getStep(), OrderStepEnum.PROJECT_WAIT.getStep());

    public final static List<String> WAIT_DELIVER = Arrays.asList(OrderStepEnum.ORDER_WAIT.getStep());

    public final static List<String> DELIVERED = Arrays.asList(OrderStepEnum.DATA_WAIT_EXAM.getStep(), OrderStepEnum.DATA_WAIT_SUBMIT.getStep(), OrderStepEnum.QUESTION_WAIT_EXAM.getStep(),
            OrderStepEnum.QUESTION_WAIT_SUBMIT.getStep());

    public final static List<String> COMPLETE = Arrays.asList(OrderStepEnum.END.getStep());

    public final static List<String> CLOSE = Arrays.asList(OrderStepEnum.ORDER_CLOSE.getStep());

    public final static List<String> REFUND_SUCCESS = Arrays.asList(OrderStepEnum.ORDER_REFUND.getStep());

    /**
     * 根据步骤获取订单状态
     * @param step
     * @return
     */
    public static String getStateByStep(String step){
        if(WAIT_PAY.contains(step)){
            return OrderStateEnum.WAIT_PAY.getState();
        }else if(WAIT_DELIVER.contains(step)){
            return OrderStateEnum.WAIT_DELIVER.getState();
        }else if(DELIVERED.contains(step)){
            return OrderStateEnum.DELIVERED.getState();
        }else if(COMPLETE.contains(step)){
            return OrderStateEnum.COMPLETE.getState();
        }else if(CLOSE.contains(step)){
            return OrderStateEnum.CLOSE.getState();
        }else if(REFUND_SUCCESS.contains(step)){
            return OrderStateEnum.REFUND_SUCCESS.getState();
        }
        return null;
    }
}
